﻿@{
    ViewBag.Title = "学年学期管理";
    Layout = "~/Views/Shared/_GridCommonLayout.cshtml";
}




<!--begin grid code-->


<section id="widget-grid" class="">
    <div class="row">

        <!--Operation-->
        <div class="heading-buttons">


            <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                <h1 class="page-title txt-color-blueDark"><i class="fa fa-calendar "></i>
                    学年学期管理
			
                </h1>
            </div>
            <div class="buttons pull-right">

                <button type="button" class="btn btn-success btn-labeled "
                    data-bind="click: $root.showAddBefore">
                    <span class="btn-label"><i class="glyphicon glyphicon-plus"></i>
                    </span>添加记录</button>

                <button type="button" class="btn btn-primary btn-labeled "
                    data-bind="click: $root.onDataDeleting">
                    <span class="btn-label"><i class="glyphicon glyphicon-remove"></i>
                    </span>批量删除</button>


            </div>
            <div style="clear: both;">
            </div>
        </div>
        <!--/Operation-->




        <!--Search-->
        <div class="filter-bar">
            <form id="formSearch">
                <div class="lbl glyphicons search" style="cursor: pointer;" data-bind="click: $root.search">
                    <i></i>筛选
                </div>
                <div>
                    <label>起始年：</label><div class='input-append'>
                        <input id='txtbSrIYearFirst' name='txtbSrIYearFirst' type='text' placeholder='起始年' class='input-mini' style='width: 120px;' /></div>
                </div>
                <div class="clearfix">
                </div>
            </form>
        </div>
        <!--/search-->



        <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12 sortable-grid ui-sortable">
            <div id="wid-id-0" class="jarviswidget jarviswidget-color-darken jarviswidget-sortable" data-widget-editbutton="false">
                <header>
                    <span class="widget-icon"><i class="fa fa-table"></i></span>
                    <h2>学年学期</h2>
                </header>
                <div style="margin-top: 35px;">
                    <div class="jarviswidget-editbox"></div>
                    <div class="widget-body no-padding">
                        <div role="grid" id="providerGrid" class="dataTables_wrapper form-inline">
                            <div class="table-responsive">

                                <div class="dt-wrapper" style="overflow-y: auto;">
                                    <table class="table table-striped table-bordered table-hover checkboxs">
                                        <!--table head-->
                                        <thead>
                                            <tr>
                                                <th style="width: 1%">
                                                    <input type="checkbox" value="0" />
                                                </th>
                                                <!-- ko foreach: headers -->
                                                <th class="center ">
                                                    <a href="#" data-bind="text: displayText@*, click: $root.sort*@" style="color: black"></a>
                                                    <i class="icon-circle-arrow-up" data-bind="    visible: value == $root.orderBy() && $root.isAsc()"></i>
                                                    <i class="icon-circle-arrow-down" data-bind="    visible: value == $root.orderBy() && !$root.isAsc()"></i>
                                                </th>
                                                <!-- /ko -->
                                                <th class="center" style="width: 60px">操作
                                                </th>
                                            </tr>
                                        </thead>
                                        <!--/table head-->
                                        <!--table body(Provider list)-->
                                        <tbody data-bind="foreach: recordSet">
                                            <tr class="selectable" onclick="">
                                                <td class="center">
                                                    <input type="checkbox" name="userSelector" data-bind="value: Id" />
                                                    <input type="hidden" data-bind="value: Id, attr: { id: Id }" />
                                                </td>

                                                <td class='center'><strong data-bind='text: Id'></strong></td>
                                                <td class='center'><strong data-bind='text: STermName'></strong></td>
                                                <td class='center'><strong data-bind='text: IYearFirst'></strong></td>


                                                <td class="center">
                                                    <a href="#" class="btn-action glyphicons pencil btn-success" data-bind="click: $root.showUpdateModal">
                                                        <i></i></a>
                                                </td>
                                            </tr>
                                        </tbody>
                                        <!--/table body( Provider list)-->

                                    </table>

                                </div>



                                <!-- 分页 -->
                                <ul class="pagination pagination-alt">
                                    <li>
                                        <a data-bind="click: firstPage"><i class="fa fa-fast-backward "></i></a>
                                    </li>
                                    <li>
                                        <a data-bind="click: prevPage"><i class="fa  fa-backward  "></i></a>
                                    </li>
                                    <li>
                                        <a>
                                            <input id="toPage" type="text" data-bind="value: pageIndex, event: { change: $root.changePageIndex }" style="width: 25px;" />
                                            /共<span data-bind="html: totalPages"></span>页 
                                        </a>
                                    </li>
                                    <li>
                                        <a data-bind="click: nextPage"><i class="fa fa-forward "></i></a>
                                    </li>
                                    <li>
                                        <a data-bind="click: lastPage"><i class="fa fa-fast-forward "></i></a>
                                    </li>
                                </ul>

                                <div class="dt-top-row total  ">
                                    当前记录共：<span data-bind="html: totalCount"></span>条
                                </div>
                                <!--end 分页-->
                            </div>

                            <!-- /分页 -->


                        </div>

                        <!-- /分页 -->




                    </div>
                </div>

            </div>




        </article>

    </div>
    <!--end row-->
</section>


<!--DeanTerm详细对话框-->
<div id="DeanTermMessageModal" class="modal fade" id="ProviderMessageModal" tabindex="-1" role="dialog"
    aria-labelledby="DeanTermMessageModalLabel" aria-hidden="true">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×</button>
            <h3>学年学期详细信息
            </h3>
        </div>

        <div class="modal-body">
            <input type='hidden' id='txtbID' name='txtbID' />
            <form class="form-horizontal" id="formDeanTerm" data-bind="with: NodeValue">

                <div class='control-group'>
                    <label class='control-label'>学期名称:</label><div class='controls'>
                        <input type='text' id='txtbSTermName' name='txtbSTermName' placeholder='' class='span10' data-bind='value:STermName' />
                    </div>
                </div>
                <div class='control-group'>
                    <label class='control-label'>起始年:</label><div class='controls'>
                        <input type='text' id='txtbIYearFirst' name='txtbIYearFirst' placeholder='起始年' class='span10' data-bind='value:IYearFirst' />
                    </div>
                </div>

            </form>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">
                取消</button>
            <button id="btnSaveOrUpdateModel" class="btn btn-primary" aria-hidden="true" data-bind=" click: onDataAddingOrUpdate">
                确定</button>
        </div>
    </div>
    <!--end div content-->
</div>
<!--/详细DeanTerm对话框-->




<script type="text/javascript">

    var gdViewModel;
    $(function () {
        $._messengerDefaults = {
            extraClasses: 'messenger-fixed messenger-theme-future messenger-on-bottom messenger-on-right'
        }; //默认提示位置;


        var options = {

            dialogId: "DeanTermMessageModal", //添加对话框

            pageSize: 20, //分页大小
            hidId: $("#txtbID"),
            SaveUpdateBtn: $("#btnSaveOrUpdateModel"),
            frmElement: $("#formDeanTerm"),

            //节点数据
            NodeValue: ko.observable({

                Id: 0,
                STermName: '',
                IYearFirst: 0,


            }),


            //用户列表Grid头部列名称
            headers: [


						 { displayText: 'ID', value: 'Id', width: 'auto' },
 { displayText: '学期名称', value: 'STermName', width: 'auto' },
 { displayText: '起始年', value: 'IYearFirst', width: 'auto' }


            ],

            //默认的排序方式
            defaultOrderBy: "Id",
            //用户查询URL
            dataQueryUrlAccessor: function () {
                return "/api/DeanTerm/GetByPage";
            },

            //添加用户URL
            dataAddUrlAccessor: function () { return "/api/DeanTerm/Post"; },
            dataUpdateAccessor: function (key) { return "/api/DeanTerm/Put/" + key; },
            dataNodeSelect: function (id) {
                return "/api/DeanTerm/get/" + id;
            },

            dataDeleteAccessor: function (data) {
                var userIDs = "";
                var check = $("input:checked");  //得到所有被选中的checkbox
                check.each(function (i) {        //循环拼装被选中项的值
                    userIDs = userIDs + ',' + $(this).val();
                });
                //清除多余的分割号
                userIDs = dropRsplit(userIDs, ",");
                if (userIDs != "") {
                    return appendQueryString("/api/DeanTerm/DeleteIds", { ids: userIDs });
                } else
                    return "";
            }
			, initEd: function () {
			    //gird初始化的后置事件 信息

			}
             , showDlgBefore: function () {
             }

            , changeEnd: function () {

            }
            , showDetailEnd: function () {
            }


        };

        gdViewModel = new gridViewModel(options);


        gdViewModel.init();
        ko.applyBindings(gdViewModel);


        options.frmElement.validate({
            rules: {


                txtbId: { required: true, digits: true }, txtbSTermName: { maxlength: 50 }, txtbIYearFirst: { digits: true }



            },
            messages: {


                txtbId: { required: '必填项', digits: '必须是整数' }, txtbSTermName: { maxlength: '最大长度为25' }, txtbIYearFirst: { digits: '必须是整数' }

            }
        });


    });

</script>






<!--/end grid code-->
